package org.learn.java.thread;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Thread t2 = new MyThread(null, "线程2");
		Thread t1 = new MyThread(t2, "线程1");
		t1.start();
	}

	static class MyThread extends Thread{

		private Thread t;
		public MyThread(Thread t,String name){
			this.t=t;
			super.setName(name);
		}
		@Override
		public void run() {
			
			System.out.println("----1----");
			
			if(t!=null){
				t.start();
				try {
					//t.join();
					t.yield();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				System.out.println("----2----");
			}
			System.out.println(Thread.currentThread().getName());
		}
		
	}
}
